﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ActorModel.Engine.Core
{
    public class StateChangingNotifier<TState>
    {
//        private readonly IDictionary<int, TState> sharedMemory = new Dictionary<int, TState>();

        public event Action<ConnectorStateEventArgs<TState>> StateUpdated;

        protected virtual void OnStateUpdated(ConnectorStateEventArgs<TState> obj)
        {
            var handler = this.StateUpdated;
            if (handler != null)
            {
                handler(obj);
            }
        }

        public void UpdateState(int id, TState state)
        {
//            if (this.sharedMemory.ContainsKey(id))
//            {
//                this.sharedMemory[id] = state; 
//            }
//            else
//            {
//                this.sharedMemory.Add(id, state);
//            }

            this.OnStateUpdated(new ConnectorStateEventArgs<TState>(id, state));
        }
    }
}
